package streamAPI.operators;

import org.apache.flink.api.common.functions.FilterFunction;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import streamAPI.source.MyNoParallelSource;

/**
 * @author yue.cao
 * @since 09-28-2020
 */
public class DemoWithFilter {

	public static void main(String[] args) throws Exception {
		StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
		DataStreamSource<Long> stream = env.addSource(new MyNoParallelSource());
		stream.filter(new FilterFunction<Long>() {
			@Override
			public boolean filter(Long value) throws Exception {
				return value % 2 == 0;
			}
		}).print().setParallelism(1);
		env.execute();
	}
}
